package mulegame;

import static org.junit.Assert.*;

import java.awt.Color;

import org.junit.Test;

public class PlayerTest {
	
	// tests getScore() method in Player
	// tests whether Player's score is as expected
	@Test
	public void testGetScore() {
		
		Player p = new Player("BeanSter", Player.Race.CARIBOUER, Color.GREEN, GameConfig.Difficulty.BEGINNER);
		int expectedScore = p.getEnergy()+p.getFood()+p.getMoney()+p.getOre();
		
		assertEquals("Player initial Score must be 1012", expectedScore, p.getScore());
	}
	
	// tests charge() method in Player when Player has enough money to be charged amount
	// tests whether method returns true
	// tests whether Player's money is as expected
	@Test
	public void testChargeWithSufficientMoney(){
		
		Player p = new Player("BeanSter", Player.Race.CARIBOUER, Color.GREEN, GameConfig.Difficulty.BEGINNER);
		int charge = 100;
		int expectedMoney = p.getMoney() - charge;

		assertTrue("Player.charge(charge) should've returned true", p.charge(charge));
		
		assertEquals("Player should now have 900 money", expectedMoney, p.getMoney());
	}
	
	// tests charge() method in Player when Player doesn't have enough money to be charged amount
	// tests whether method returns false
	// tests whether Player's money is as expected
	@Test
	public void testChargeWithInsufficientMoney(){
		
		Player p = new Player("BeanSter", Player.Race.CARIBOUER, Color.GREEN, GameConfig.Difficulty.BEGINNER);
		int charge = 2000;
		int expectedMoney = p.getMoney();

		assertFalse("Player.charge(charge) should've returned false", p.charge(charge));
		
		assertEquals("Player should still have 1000 money", expectedMoney, p.getMoney());
	}
}
